<?php
include_once($_SERVER['DOCUMENT_ROOT'] . '/sandbox/banco/config.php');
include_once($_SERVER['DOCUMENT_ROOT'] . '/sandbox/modelos/m_logging.php');

class CURL{
	var $retorno, $info;
	
	public function __construct($url, $tipo, $dados) {
		$this->log = new Logging($_SERVER['DOCUMENT_ROOT'] . '/sandbox/mylog.log');
		
		if ($tipo == 'XML') {
			$cabecalho = "Content-Type: application/xml; charset=ISO-8859-1";
		} elseif ($tipo == 'HTTP') {
			$cabecalho = "Content-Type: application/x-www-form-urlencoded; charset=ISO-8859-1";
		}
		
		$curl = curl_init($url);
		curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($curl, CURLOPT_HTTPHEADER, Array($cabecalho));
		curl_setopt($curl, CURLOPT_POSTFIELDS, $dados);
		//$this->log->lwrite('Notificacao. URL: ' . $url . ' / Dados: ' . $dados);
		$this->retorno = curl_exec($curl);
		$this->info = curl_error($curl);
		curl_close($curl);
	}
}
?>